<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.2">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"wrr123.github.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.json"};
  </script>

  <meta name="description" content="talk is cheap, show me the code">
<meta property="og:type" content="website">
<meta property="og:title" content="一缕烟气">
<meta property="og:url" content="https://wrr123.github.io/page/27/index.html">
<meta property="og:site_name" content="一缕烟气">
<meta property="og:description" content="talk is cheap, show me the code">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="田园隐士">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://wrr123.github.io/page/27/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>一缕烟气</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="一缕烟气" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">一缕烟气</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">沧海月明珠有泪，蓝田日暖玉生烟</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-jqGrid/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-jqGrid/" class="post-title-link" itemprop="url">notebook-jqGrid</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>926</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Tue-Dec-24-16-38-48-CST-2019"><a href="#Tue-Dec-24-16-38-48-CST-2019" class="headerlink" title="Tue Dec 24 16:38:48 CST 2019"></a>Tue Dec 24 16:38:48 CST 2019</h1><h2 id="表格加载完成后，可对某些字段执行隐藏和可见操作"><a href="#表格加载完成后，可对某些字段执行隐藏和可见操作" class="headerlink" title="表格加载完成后，可对某些字段执行隐藏和可见操作?"></a>表格加载完成后，可对某些字段执行隐藏和可见操作?</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">在实际生产中，经常会遇到这样的情况，当jqgrid加载完成对应的数据列之后，点击某操作需要减少或增加一列。针对这种情况如何处理呢？</span><br><span class="line"></span><br><span class="line">这里提供一种方法，就是基于jqgrid提供的hideCol方法。具体使用方式：</span><br><span class="line"></span><br><span class="line">$(&quot;#jqGrid&quot;).jqGrid(&#x27;hideCol&#x27;, [&quot;column&quot;]).trigger(&quot;reloadGrid&quot;);</span><br><span class="line">通过上的方法即可将不需要显示的列进行隐藏操作。如果参数为一个列名则隐藏此列，如果给定的是数组则隐藏指定的所有列。格式： [“name1”,”name2”]</span><br><span class="line"></span><br><span class="line">对应的肯定有显示showCol方法了，具体使用方式与上面相同：</span><br><span class="line"></span><br><span class="line">$(&quot;#jqGrid&quot;).jqGrid(&#x27;showCol&#x27;, [&quot;column&quot;]).trigger(&quot;reloadGrid&quot;);</span><br><span class="line">显示列。column可以是数组[“name1”,”name2”],但是name1或者name2必须是colModel中的name。</span><br><span class="line"></span><br><span class="line">当然，上面只是通过隐藏和显示来达到动态修改列表的，如果需要动态新增内容可通过setColProp方法来操作。</span><br><span class="line"></span><br><span class="line">setColProp设置新的属性，对于动态改变列属性是非常有用的，但是有些属性的修改并不会起效。用法：</span><br><span class="line"></span><br><span class="line">$(&quot;#jqGrid&quot;).setColProp(&#x27;colname&#x27;,&#123;editoptions:&#123;value:“True:False”&#125;&#125;);</span><br></pre></td></tr></table></figure>
<h3 id="2020-03-23-16-58-10-星期一"><a href="#2020-03-23-16-58-10-星期一" class="headerlink" title="2020-03-23 16:58:10 星期一"></a>2020-03-23 16:58:10 星期一</h3><h5 id="单元格自动换行"><a href="#单元格自动换行" class="headerlink" title="单元格自动换行"></a>单元格自动换行</h5><p>添加如下样式：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.ui-jqgrid</span> <span class="selector-tag">tr</span><span class="selector-class">.jqgrow</span> <span class="selector-tag">td</span> &#123;</span><br><span class="line"><span class="attribute">white-space</span>: normal <span class="meta">!important</span>;</span><br><span class="line"><span class="attribute">height</span>:auto;</span><br><span class="line"><span class="attribute">vertical-align</span>:text-top;</span><br><span class="line"><span class="attribute">padding-top</span>:<span class="number">2px</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-linux/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-linux/" class="post-title-link" itemprop="url">notebook-linux</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>386</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Tue-Oct-29-14-43-17-CST-2019"><a href="#Tue-Oct-29-14-43-17-CST-2019" class="headerlink" title="Tue Oct 29 14:43:17 CST 2019"></a>Tue Oct 29 14:43:17 CST 2019</h1><h2 id="rm-删除文件时，通配符的使用？"><a href="#rm-删除文件时，通配符的使用？" class="headerlink" title="rm 删除文件时，通配符的使用？"></a>rm 删除文件时，通配符的使用？</h2><ul>
<li><code>*</code> 匹配任意多个字符</li>
<li><code>?</code> 匹配任意单个字符</li>
<li><code>[]</code> 匹配之间的任意一个字符</li>
<li><code>^</code> 表示匹配结果取反的意思，注意这个通配符必须要在[]中使用</li>
<li><code>&#123;&#125;</code> 表示符合括号内包含的多个文件, 如 <code>ls &#123;*.log,*.txt&#125; 查询‘.log’和“.txt”结尾的文件</code></li>
</ul>
<h2 id="rm删除多级目录下的文件？"><a href="#rm删除多级目录下的文件？" class="headerlink" title="rm删除多级目录下的文件？"></a><code>rm</code>删除多级目录下的文件？</h2><ul>
<li><code>find . -name &quot;*.log&quot;|xargs rm -f</code></li>
</ul>
<h1 id="Wed-Nov-13-09-50-50-CST-2019"><a href="#Wed-Nov-13-09-50-50-CST-2019" class="headerlink" title="Wed Nov 13 09:50:50 CST 2019"></a>Wed Nov 13 09:50:50 CST 2019</h1><h2 id="如何写一个sh脚本，并可以向其中传递参数？"><a href="#如何写一个sh脚本，并可以向其中传递参数？" class="headerlink" title="如何写一个sh脚本，并可以向其中传递参数？"></a>如何写一个sh脚本，并可以向其中传递参数？</h2><h1 id="Fri-Dec-13-08-38-08-CST-2019"><a href="#Fri-Dec-13-08-38-08-CST-2019" class="headerlink" title="Fri Dec 13 08:38:08 CST 2019"></a>Fri Dec 13 08:38:08 CST 2019</h1><h2 id="查询使用端口的命令"><a href="#查询使用端口的命令" class="headerlink" title="查询使用端口的命令"></a>查询使用端口的命令</h2><p><code>netstat -anp|grep 8080</code></p>
<h2 id="mac下查询某个端口是否被占用"><a href="#mac下查询某个端口是否被占用" class="headerlink" title="mac下查询某个端口是否被占用"></a>mac下查询某个端口是否被占用</h2><blockquote>
<p>方法一：<br>//查看80口是否被占用<br>sudo lsof -i :80<br>方法二：<br>netstat -anp tcp | grep 80</p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-macOS/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-macOS/" class="post-title-link" itemprop="url">notebook-macOS</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>549</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Tue-Oct-29-10-35-33-CST-2019"><a href="#Tue-Oct-29-10-35-33-CST-2019" class="headerlink" title="Tue Oct 29 10:35:33 CST 2019"></a>Tue Oct 29 10:35:33 CST 2019</h1><h2 id="在macOS-X及以上下载jdk1-6和卸载jdk1-6？"><a href="#在macOS-X及以上下载jdk1-6和卸载jdk1-6？" class="headerlink" title="在macOS X及以上下载jdk1.6和卸载jdk1.6？"></a>在macOS X及以上下载jdk1.6和卸载jdk1.6？</h2><ul>
<li><a target="_blank" rel="noopener" href="https://gitissue.com/issues/5a8c7e633a40eb3c8f293346">Mac系统下安装及卸载JDK</a></li>
</ul>
<h1 id="Fri-Dec-13-13-29-04-CST-2019"><a href="#Fri-Dec-13-13-29-04-CST-2019" class="headerlink" title="Fri Dec 13 13:29:04 CST 2019"></a>Fri Dec 13 13:29:04 CST 2019</h1><h2 id="文件编码的转换？"><a href="#文件编码的转换？" class="headerlink" title="文件编码的转换？"></a>文件编码的转换？</h2><ul>
<li><code>iconv</code> <code>iconv -c -f gbk -t utf8 test.txt &gt; test.txt.utf8</code></li>
<li><code>enca</code></li>
</ul>
<h2 id="MacOS系统Docker默认存储路径迁移方法"><a href="#MacOS系统Docker默认存储路径迁移方法" class="headerlink" title="MacOS系统Docker默认存储路径迁移方法?"></a>MacOS系统Docker默认存储路径迁移方法?</h2><p><a target="_blank" rel="noopener" href="https://juejin.im/post/5c3884ad6fb9a049d05df4a9">掘金blog</a></p>
<h1 id="Sat-Dec-14-21-00-37-CST-2019"><a href="#Sat-Dec-14-21-00-37-CST-2019" class="headerlink" title="Sat Dec 14 21:00:37 CST 2019"></a>Sat Dec 14 21:00:37 CST 2019</h1><h2 id="文件传输命令"><a href="#文件传输命令" class="headerlink" title="文件传输命令"></a>文件传输命令</h2><ul>
<li><code>rsync</code> 远程文件同步工具</li>
</ul>
<h1 id="Fri-Dec-27-10-56-23-CST-2019"><a href="#Fri-Dec-27-10-56-23-CST-2019" class="headerlink" title="Fri Dec 27 10:56:23 CST 2019"></a>Fri Dec 27 10:56:23 CST 2019</h1><h2 id="zsh下的docker插件无效的原因？"><a href="#zsh下的docker插件无效的原因？" class="headerlink" title="zsh下的docker插件无效的原因？"></a>zsh下的docker插件无效的原因？</h2><ul>
<li>用户目录下的缓存文件问题<br>需清除<code>rm ~/.zcompdump*</code></li>
</ul>
<h1 id="2019年12月28日-星期六-20时38分53秒-CST"><a href="#2019年12月28日-星期六-20时38分53秒-CST" class="headerlink" title="2019年12月28日 星期六 20时38分53秒 CST"></a>2019年12月28日 星期六 20时38分53秒 CST</h1><h2 id="mac-java开发-推荐的一些软件"><a href="#mac-java开发-推荐的一些软件" class="headerlink" title="mac java开发 推荐的一些软件"></a>mac java开发 推荐的一些软件</h2><ul>
<li>alfred <em>分普通版和加强版</em></li>
<li>dash 查看文档</li>
<li>iterm 源生的终端工具，可配合zsh使用，最好安装<code>oh my zsh</code></li>
<li>sublime-text 编辑器 <em>付费的</em></li>
<li>JetBrains系列的产品，如idea、pycharm等等</li>
<li>homebrew</li>
<li>source tree 最好用的git GUI客户端</li>
<li>beyond-compare 文件比较工具</li>
<li>kaleidoscope Mac下的文件比较工具</li>
<li>codeRunner 一款编程软件</li>
<li>Mweb 专业的markdown生成软件 <em>付费的</em></li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-maven/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-maven/" class="post-title-link" itemprop="url">notebook-maven</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Tue-Oct-29-09-46-47-CST-2019"><a href="#Tue-Oct-29-09-46-47-CST-2019" class="headerlink" title="Tue Oct 29 09:46:47 CST 2019"></a>Tue Oct 29 09:46:47 CST 2019</h1><h2 id="使用maven导入项目需要依赖的jar包时，明明在本地仓库存在需要的jar包，但是jar包导入不到项目中？"><a href="#使用maven导入项目需要依赖的jar包时，明明在本地仓库存在需要的jar包，但是jar包导入不到项目中？" class="headerlink" title="使用maven导入项目需要依赖的jar包时，明明在本地仓库存在需要的jar包，但是jar包导入不到项目中？"></a>使用maven导入项目需要依赖的jar包时，明明在本地仓库存在需要的jar包，但是jar包导入不到项目中？</h2><ol>
<li>一种可能性：pom文件中有一些jar在本地仓库没有，导致所有的jar包都引入不了。</li>
</ol>
<h2 id="pom文件中标签下的标签内容的含义？"><a href="#pom文件中标签下的标签内容的含义？" class="headerlink" title="pom文件中标签下的标签内容的含义？"></a>pom文件中<dependency>标签下的<scope>标签内容的含义？</scope></dependency></h2><ul>
<li>compile<blockquote>
<p>默认的scope。任何定义在compile scope下的依赖将会在所有的class paths下可用。maven工程会将其打包到最终的artifact中。如果你构建一个WAR类型的artifact，那么在compile scope下引用的JAR文件将会被集成到WAR文件内。</p>
</blockquote>
</li>
<li>provided<blockquote>
<p>这个scope假定对应的依赖会由运行这个应用的JDK或者容器来提供。最好的例子就是servlet API。任何在provided scope下定义的依赖在构建时的类路径里是可用的，但是不会被打包到最终的artifact中。如果是一个WAR的文件，servlet API在构建时的类路径里是可用的，但是并不会被打包到WAR文件中</p>
</blockquote>
</li>
<li>rumtime<blockquote>
<p>在runtime scope下定义的依赖只会在运行期可用，而在构建期的类路径下不可用。这些依赖将会被打包到最终的artifact中。比如你有一个基于web的应用需要在运行时访问MySQL数据库。你的代码没有任何MySQL数据库驱动的硬依赖。你的代码仅仅是基于JDBC API来编写，在构建期并不需要MySQL数据库驱动。然而，在运行期，就需要相应的驱动来操作MySQL数据库了。因此，这个驱动应该被打包到最终的artifact中。</p>
</blockquote>
</li>
<li>test<blockquote>
<p>只用于测试变异的依赖（比如JUnit），execution必须定义在test scope下。这些依赖不会被打包到最终的artifact中。</p>
</blockquote>
</li>
<li>system<blockquote>
<p>于provided scope很像。唯一的区别在于，在system scope中，你需要告诉Maven如何去找到这个依赖。如果你要引用的依赖在Maven仓库中不存在时，就可以用这个scope。不推荐使用system依赖。</p>
</blockquote>
</li>
</ul>
<h2 id="maven配置镜像仓库和伺服仓库"><a href="#maven配置镜像仓库和伺服仓库" class="headerlink" title="maven配置镜像仓库和伺服仓库"></a>maven配置镜像仓库和伺服仓库</h2><ul>
<li>一般镜像仓库只配置一个， 伺服仓库可以配置多个。</li>
</ul>
<h2 id="maven项目编译报错，error-reading-file-error-in-opening-zip-file"><a href="#maven项目编译报错，error-reading-file-error-in-opening-zip-file" class="headerlink" title="maven项目编译报错，error reading file:.. error in opening zip file?"></a>maven项目编译报错，<code>error reading file:.. error in opening zip file</code>?</h2><ul>
<li>在本地仓库删除报错的jar包，将其删除掉，然后从远程仓库重新下载。</li>
</ul>
<h1 id="Tue-Nov-12-13-56-49-CST-2019"><a href="#Tue-Nov-12-13-56-49-CST-2019" class="headerlink" title="Tue Nov 12 13:56:49 CST 2019"></a>Tue Nov 12 13:56:49 CST 2019</h1><h2 id="maven打包时，跳过测试用例"><a href="#maven打包时，跳过测试用例" class="headerlink" title="maven打包时，跳过测试用例"></a>maven打包时，跳过测试用例</h2><blockquote>
<p>-DskipTests，不执行测试用例，但编译测试用例类生成相应的class文件至target/test-classes下。<br>-Dmaven.test.skip=true，不执行测试用例，也不编译测试用例类。</p>
</blockquote>
<h2 id="maven将class文件打包成一个单独的jar包？"><a href="#maven将class文件打包成一个单独的jar包？" class="headerlink" title="maven将class文件打包成一个单独的jar包？"></a>maven将class文件打包成一个单独的jar包？</h2><blockquote>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"></span><br></pre></td></tr></table></figure>
</blockquote>
<!--将class文件打成jar-->
<p><plugin><br>    <groupId>org.apache.maven.plugins</groupId><br>    <artifactId>maven-jar-plugin</artifactId><br>    <version>2.6</version><br>    <configuration><br>        <encoding>UTF-8</encoding>
    </configuration><br>    <executions><br>        <execution><br>            <phase>package</phase><br>            <goals><br>                <goal>jar</goal>
            </goals><br>            <configuration><br>                <classesDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</classesDirectory><br>                <finalName>my_jar</finalName><br>                <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory><br>                <includes><br>                    <include>com/**</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin><br>  <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"># Thu Nov 14 10:41:39 CST 2019</span><br><span class="line">## archetype plugin的学习</span><br><span class="line">1. 创建一个项目的骨架，可以从已存在的archetype库中，也可以从存在的项目中。</span><br><span class="line">2. goals</span><br><span class="line">  - archetype:generate</span><br><span class="line">  - archetype:create-from-project</span><br><span class="line">  - archetype:crawl</span><br><span class="line"></span><br><span class="line"># Mon Nov 18 17:52:09 CST 2019</span><br><span class="line">## 导入本地jar包到本地maven仓库</span><br><span class="line">`mvn install:install-file -Dfile=lombok-1.18.8.jar -DgroupId=org.projectlombok -DartifactId=lombok -Dversion=1.18.8 -Dpackaging=jar`</span><br><span class="line"></span><br><span class="line"># Tue Nov 19 13:55:50 CST 2019</span><br><span class="line">## 通过pom文件来生成一个基础的maven项目</span><br><span class="line"></span><br><span class="line"># Sat Dec  7 20:26:11 CST 2019</span><br><span class="line">## 常见maven命令的使用和含义</span><br><span class="line">1. `mvn dependency:tree ` 展示项目的jar包之间的依赖关系,可解决jar包冲突等问题。</span><br><span class="line">  - 参数 -Dverbose=true 展示详细信息</span><br><span class="line">  - 参数 -Dincludes=`groupId:artifactId:version` 只展示你需要的jar包信息</span><br><span class="line">  - 参数 -Dexcludes=`groupId:artifactId:version` 只展示你不需要的jar包信息</span><br><span class="line"></span><br><span class="line">## Fatal error compiling: 无效的标记</span><br><span class="line">  可能是项目使用的jdk版本和maven的jdk版本不一致导致的。</span><br><span class="line"></span><br><span class="line"># Sun Dec  8 21:39:09 CST 2019</span><br><span class="line">## maven中phase，plugin，goal之间的区别是什么？</span><br><span class="line">- goal是maven中执行的最小单元；</span><br><span class="line">- 一个phase或者plugin包含一个或者多个goal；</span><br><span class="line"># Tue Dec 10 10:32:05 CST 2019</span><br><span class="line">## `mvn install`产生的错误</span><br><span class="line">1. compailation failure: 名称冲突，类A的方法和类B的方法，具有相同的疑符，但两者均不隐藏对方？</span><br><span class="line">2. 子模块和父模块中存在同一个jar包依赖，以哪个为准？</span><br><span class="line">3. compailation failure: 找不到合适的方法？</span><br><span class="line">  jdk版本引入错误，可能使用了高版本的jdk</span><br><span class="line">4. compailation failure: 错误(非法字符 `\ufeff`),错误(需要class,interface,enum)?</span><br><span class="line">  编码为UTF-8，应为UTF-8 无 BOM。</span><br><span class="line">5. compailation failure: 错误(编码UTF-8的不可映射字符)?</span><br><span class="line">  编码应该UTF-8，实际上不是。</span><br><span class="line">6. exceptions: File: &#x27;java.lang.CharSequence&#x27;: Invalid byte tag in constant pool: 15 ?</span><br><span class="line"></span><br><span class="line">## 文件编码`UTF-8`和`UTF-8 无 BOM`的区别？</span><br><span class="line"></span><br><span class="line"># Wed Dec 11 13:32:54 CST 2019</span><br><span class="line">## ant(ivy),maven,gradle之间的区别和联系？</span><br><span class="line">- 时间排序(从小到大): ant&lt;maven&lt;gradle</span><br><span class="line">- 最小单元</span><br><span class="line">  ant(target), maven(goal), gradle(task)</span><br><span class="line">- 都是项目构建工具</span><br><span class="line"></span><br></pre></td></tr></table></figure></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-oracle/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-oracle/" class="post-title-link" itemprop="url">notebook-oracle</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>5k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>5 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="常用函数"><a href="#常用函数" class="headerlink" title="常用函数"></a>常用函数</h2><ol>
<li>取余函数 mod</li>
<li>对时间格式或数字格式进行截取 trunc</li>
<li>对数字进行四舍五入 round(a1, a2)<br>a1: 进行四舍五入的数字<br>a2: 从小数点的左边还是右边几位数进行四舍五入（0表示四舍五入到整数位，正数1表示四舍五入到小数点右边1位，负数1表示四舍五入到小数点左边1位）</li>
</ol>
<h1 id="Tue-Oct-29-11-23-05-CST-2019"><a href="#Tue-Oct-29-11-23-05-CST-2019" class="headerlink" title="Tue Oct 29 11:23:05 CST 2019"></a>Tue Oct 29 11:23:05 CST 2019</h1><h2 id="查询数据库的表空间？"><a href="#查询数据库的表空间？" class="headerlink" title="查询数据库的表空间？"></a>查询数据库的表空间？</h2><ul>
<li><code>select * from dba_tablespaces t;</code></li>
</ul>
<h2 id="修改表字段信息"><a href="#修改表字段信息" class="headerlink" title="修改表字段信息"></a>修改表字段信息</h2><ul>
<li><code>alter table $tableName modify $columnName varchar2(20)</code></li>
</ul>
<h1 id="Thu-Oct-31-13-57-58-CST-2019"><a href="#Thu-Oct-31-13-57-58-CST-2019" class="headerlink" title="Thu Oct 31 13:57:58 CST 2019"></a>Thu Oct 31 13:57:58 CST 2019</h1><h2 id="oracle表的唯一性隐藏字段rowid"><a href="#oracle表的唯一性隐藏字段rowid" class="headerlink" title="oracle表的唯一性隐藏字段rowid"></a>oracle表的唯一性隐藏字段rowid</h2><h1 id="Fri-Nov-1-18-07-51-CST-2019"><a href="#Fri-Nov-1-18-07-51-CST-2019" class="headerlink" title="Fri Nov  1 18:07:51 CST 2019"></a>Fri Nov  1 18:07:51 CST 2019</h1><h2 id="ora-01847-月份中日的值必须介于1和当月最后一日之间？"><a href="#ora-01847-月份中日的值必须介于1和当月最后一日之间？" class="headerlink" title="ora-01847:月份中日的值必须介于1和当月最后一日之间？"></a>ora-01847:月份中日的值必须介于1和当月最后一日之间？</h2><h1 id="Sun-Nov-3-12-30-27-CST-2019"><a href="#Sun-Nov-3-12-30-27-CST-2019" class="headerlink" title="Sun Nov  3 12:30:27 CST 2019"></a>Sun Nov  3 12:30:27 CST 2019</h1><h2 id="以后给别人导表数据的时候，最好是表结构和表数据一起导，防止数据的类型出现各种带下不一致的问题。"><a href="#以后给别人导表数据的时候，最好是表结构和表数据一起导，防止数据的类型出现各种带下不一致的问题。" class="headerlink" title="以后给别人导表数据的时候，最好是表结构和表数据一起导，防止数据的类型出现各种带下不一致的问题。"></a>以后给别人导表数据的时候，最好是表结构和表数据一起导，防止数据的类型出现各种带下不一致的问题。</h2><h1 id="Mon-Nov-4-12-29-24-CST-2019"><a href="#Mon-Nov-4-12-29-24-CST-2019" class="headerlink" title="Mon Nov  4 12:29:24 CST 2019"></a>Mon Nov  4 12:29:24 CST 2019</h1><h2 id="oracle数据库的监听问题，描述查看监听的状态-lsnrctl-status-时，执行的很慢-查看1521端口时，显示监听已经启动了，但是查看监听的状态时，显示监听是没有启动的-有报错信息如下：-64-bit-Windows-Error-61-Unkonwn-error"><a href="#oracle数据库的监听问题，描述查看监听的状态-lsnrctl-status-时，执行的很慢-查看1521端口时，显示监听已经启动了，但是查看监听的状态时，显示监听是没有启动的-有报错信息如下：-64-bit-Windows-Error-61-Unkonwn-error" class="headerlink" title="oracle数据库的监听问题，描述查看监听的状态(lsnrctl status)时，执行的很慢;查看1521端口时，显示监听已经启动了，但是查看监听的状态时，显示监听是没有启动的;有报错信息如下：[64-bit Windows Error:61:Unkonwn error]"></a>oracle数据库的监听问题，描述<code>查看监听的状态(lsnrctl status)时，执行的很慢;查看1521端口时，显示监听已经启动了，但是查看监听的状态时，显示监听是没有启动的;有报错信息如下：[64-bit Windows Error:61:Unkonwn error]</code></h2><ul>
<li>检查监听的日志文件是不是太大了（如达到了4G），若是，需删除此日志文件</li>
<li>查看日志文件所在位置的sql<code>select name, value from v$diag_info;</code></li>
</ul>
<h1 id="Wed-Nov-6-11-04-41-CST-2019"><a href="#Wed-Nov-6-11-04-41-CST-2019" class="headerlink" title="Wed Nov  6 11:04:41 CST 2019"></a>Wed Nov  6 11:04:41 CST 2019</h1><h2 id="exp命令"><a href="#exp命令" class="headerlink" title="exp命令"></a>exp命令</h2><ul>
<li>导出指定数量的表数据文件<blockquote>
<p><code>exp cboms/cboms@32.202.32.21/cboms file=cboms.dmp log=cboms.log query=&quot;&#39;where rownum&lt;10001&#39;&quot; tables=&#39;%%&#39;</code></p>
</blockquote>
</li>
<li>导出数据库表结构<blockquote>
<p><code>exp cboms/cboms file=cboms_jiegou.dmp tables=%% rows=n</code></p>
</blockquote>
</li>
</ul>
<h2 id="新建数据库的表空间"><a href="#新建数据库的表空间" class="headerlink" title="新建数据库的表空间"></a>新建数据库的表空间</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">--oracle创建用户并授权</span></span><br><span class="line"></span><br><span class="line"><span class="comment">--创建用户临时表空间 </span></span><br><span class="line"><span class="keyword">create</span> temporary tablespace cboms_index tempfile <span class="string">&#x27;/home/oracle/oraData/cboms_index01.dbf&#x27;</span> size <span class="number">50</span>m autoextend <span class="keyword">on</span> next <span class="number">50</span>m maxsize <span class="number">20480</span>m extent management <span class="keyword">local</span>; </span><br><span class="line"></span><br><span class="line"><span class="comment">--创建用户表空间</span></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span>space cboms datafile <span class="string">&#x27;/home/oracle/oraData/cboms01.dbf&#x27;</span> size <span class="number">50</span>m autoextend <span class="keyword">on</span> next <span class="number">100</span>m maxsize unlimited(<span class="number">20480</span>m extent management <span class="keyword">local</span>);</span><br><span class="line"></span><br><span class="line"><span class="comment">--创建用户</span></span><br><span class="line"><span class="keyword">create</span> <span class="keyword">user</span> cboms identified <span class="keyword">by</span> cboms <span class="keyword">default</span> tablespace cboms temporary tablespace cboms_index;</span><br><span class="line"><span class="comment">--授予权限</span></span><br><span class="line"><span class="keyword">grant</span> unlimited tablespace <span class="keyword">to</span> cboms;<span class="comment">--授予cboms用户使用表空间的权限</span></span><br><span class="line"><span class="keyword">grant</span> <span class="keyword">create</span> session <span class="keyword">to</span> cboms;<span class="comment">--授予cboms用户创建session的权限，即登陆权限</span></span><br><span class="line"><span class="keyword">grant</span> <span class="keyword">ALL</span> privileges <span class="keyword">to</span> cboms;<span class="comment">--这条比较重要，授予所有权限(all)给用户(cboms)</span></span><br><span class="line"><span class="keyword">GRANT</span> DBA <span class="keyword">TO</span> cboms;</span><br><span class="line"></span><br><span class="line"><span class="comment">--查看权限</span></span><br><span class="line"><span class="keyword">select</span> <span class="operator">*</span> <span class="keyword">from</span> user_sys_privs;<span class="comment">--查看当前用户所有权限</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="operator">*</span> <span class="keyword">FROM</span> DBA_SYS_PRIVS <span class="keyword">WHERE</span> GRANTEE <span class="keyword">IN</span> (<span class="string">&#x27;cboms&#x27;</span>);</span><br></pre></td></tr></table></figure>
<h2 id="查看表空间"><a href="#查看表空间" class="headerlink" title="查看表空间"></a>查看表空间</h2><p><code>SELECT tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space FROM dba_data_files ORDER BY tablespace_name;</code></p>
<h2 id="新增表空间"><a href="#新增表空间" class="headerlink" title="新增表空间"></a>新增表空间</h2><p><code>alter tablespace cboms add datafile  &#39;/home/oracle/oraData/cboms02.dbf&#39; size 50m autoextend on next 100m maxsize 20480m;</code></p>
<h2 id="删除用户和表空间"><a href="#删除用户和表空间" class="headerlink" title="删除用户和表空间"></a>删除用户和表空间</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">删除用户和表空间,对于单个<span class="keyword">user</span>和tablespace 来说， 可以使用如下命令来完成。</span><br><span class="line">步骤一： 删除<span class="keyword">user</span></span><br><span class="line"><span class="keyword">drop</span> <span class="keyword">user</span> ×× cascade</span><br><span class="line">如：<span class="keyword">drop</span> <span class="keyword">user</span> SMCHANNEL CASCADE</span><br><span class="line">说明： 删除了<span class="keyword">user</span>，只是删除了该<span class="keyword">user</span>下的schema objects，是不会删除相应的tablespace的。</span><br><span class="line">步骤二： 删除tablespace</span><br><span class="line"><span class="keyword">DROP</span> TABLESPACE tablespace_name INCLUDING CONTENTS <span class="keyword">AND</span> DATAFILES;</span><br></pre></td></tr></table></figure>
<h2 id="imp"><a href="#imp" class="headerlink" title="imp"></a>imp</h2><h3 id="IMP-00015-following-statement-failed-because-the-object-already-exists"><a href="#IMP-00015-following-statement-failed-because-the-object-already-exists" class="headerlink" title="IMP-00015: following statement failed because the object already exists"></a>IMP-00015: following statement failed because the object already exists</h3><ul>
<li>设置参数<code>ignore=y</code>(忽略创建错误)<h3 id="导入指定表的数据"><a href="#导入指定表的数据" class="headerlink" title="导入指定表的数据"></a>导入指定表的数据</h3><code>imp userid=cboms/cboms file=wxrcb_data/cboms_data.dmp tables=&#39;sys_data_dict,sys_data_dict_type&#39; log=imp.log data_only=y</code></li>
</ul>
<h2 id="可以判断一个字段以数字结尾吗？"><a href="#可以判断一个字段以数字结尾吗？" class="headerlink" title="可以判断一个字段以数字结尾吗？"></a>可以判断一个字段以数字结尾吗？</h2><ul>
<li>正则表达式的like <code>regexp_like</code></li>
</ul>
<h2 id="函数：将不同行的字段合并到同一列上的？"><a href="#函数：将不同行的字段合并到同一列上的？" class="headerlink" title="函数：将不同行的字段合并到同一列上的？"></a>函数：将不同行的字段合并到同一列上的？</h2><ul>
<li>wm_concat(column) <code>默认以逗号分隔</code></li>
<li>listagg(cloumnA, ‘,’) within group(rder by columnB)</li>
</ul>
<h1 id="Thu-Nov-7-10-03-32-CST-2019"><a href="#Thu-Nov-7-10-03-32-CST-2019" class="headerlink" title="Thu Nov  7 10:03:32 CST 2019"></a>Thu Nov  7 10:03:32 CST 2019</h1><h2 id="新增序列"><a href="#新增序列" class="headerlink" title="新增序列"></a>新增序列</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> sequence seq_arc_efile_zskwj</span><br><span class="line">minvalue <span class="number">1</span></span><br><span class="line">maxvalue <span class="number">999999999999999999</span></span><br><span class="line"><span class="keyword">start</span> <span class="keyword">with</span> <span class="number">621</span></span><br><span class="line">increment <span class="keyword">by</span> <span class="number">1</span></span><br><span class="line">nocache;</span><br></pre></td></tr></table></figure>
<h1 id="Fri-Nov-8-09-33-32-CST-2019"><a href="#Fri-Nov-8-09-33-32-CST-2019" class="headerlink" title="Fri Nov  8 09:33:32 CST 2019"></a>Fri Nov  8 09:33:32 CST 2019</h1><h2 id="在不同的表中插入语句或者在同一张表中插入多条数据？"><a href="#在不同的表中插入语句或者在同一张表中插入多条数据？" class="headerlink" title="在不同的表中插入语句或者在同一张表中插入多条数据？"></a>在不同的表中插入语句或者在同一张表中插入多条数据？</h2><h1 id="Sun-Nov-10-11-10-58-CST-2019"><a href="#Sun-Nov-10-11-10-58-CST-2019" class="headerlink" title="Sun Nov 10 11:10:58 CST 2019"></a>Sun Nov 10 11:10:58 CST 2019</h1><h2 id="给表或者字段添加注释"><a href="#给表或者字段添加注释" class="headerlink" title="给表或者字段添加注释"></a>给表或者字段添加注释</h2><ol>
<li><code>comment on table tableName is &#39;&#39;</code></li>
<li><code>comment on column tableName.columnName is &#39;&#39;</code></li>
</ol>
<h1 id="Mon-Nov-11-10-36-34-CST-2019"><a href="#Mon-Nov-11-10-36-34-CST-2019" class="headerlink" title="Mon Nov 11 10:36:34 CST 2019"></a>Mon Nov 11 10:36:34 CST 2019</h1><h2 id="del格式文件导入到oracle数据库中"><a href="#del格式文件导入到oracle数据库中" class="headerlink" title="del格式文件导入到oracle数据库中"></a>del格式文件导入到oracle数据库中</h2><h1 id="Wed-Nov-20-12-53-12-CST-2019"><a href="#Wed-Nov-20-12-53-12-CST-2019" class="headerlink" title="Wed Nov 20 12:53:12 CST 2019"></a>Wed Nov 20 12:53:12 CST 2019</h1><h2 id="换行符表示"><a href="#换行符表示" class="headerlink" title="换行符表示"></a>换行符表示</h2><blockquote>
<p>chr(13) 回车符<br>chr(10) 换行符<br>chr(9) 制表符</p>
<ul>
<li><h1 id="Thu-Dec-5-09-53-50-CST-2019"><a href="#Thu-Dec-5-09-53-50-CST-2019" class="headerlink" title="Thu Dec  5 09:53:50 CST 2019"></a>Thu Dec  5 09:53:50 CST 2019</h1></li>
</ul>
<ol>
<li>判断字符串中是否含有某个字符的函数？<br><code>instr(str, search_str, [, start_position][, nth_appearance]) instr(源字符串， 目标字符串[, 开始位置][, 匹配序号])</code></li>
<li>IF判断的多重分支？<br>一、单个IF<br>1、<br>if a=…  then<br>………<br>end if;<br>2、<br>if a=… then<br>……<br>else<br>….<br>end if;<br>二、多个IF<br>if a=..  then<br>……<br>elsif a=..  then<br>….<br>end if;</li>
</ol>
</blockquote>
<h1 id="Thu-Dec-12-10-09-08-CST-2019"><a href="#Thu-Dec-12-10-09-08-CST-2019" class="headerlink" title="Thu Dec 12 10:09:08 CST 2019"></a>Thu Dec 12 10:09:08 CST 2019</h1><h2 id="IMP-00002-failed-to-open-ers1-dmp-for-read"><a href="#IMP-00002-failed-to-open-ers1-dmp-for-read" class="headerlink" title="IMP-00002: failed to open ers1.dmp for read ??"></a>IMP-00002: failed to open ers1.dmp for read ??</h2><h2 id="ORA-12705-Cannot-access-NLS-data-files-or-invalid-environment-specified"><a href="#ORA-12705-Cannot-access-NLS-data-files-or-invalid-environment-specified" class="headerlink" title="ORA-12705: Cannot access NLS data files or invalid environment specified ??"></a>ORA-12705: Cannot access NLS data files or invalid environment specified ??</h2><h2 id="oracle数据库，sqlplus连接乱码问题？"><a href="#oracle数据库，sqlplus连接乱码问题？" class="headerlink" title="oracle数据库，sqlplus连接乱码问题？"></a>oracle数据库，sqlplus连接乱码问题？</h2><ul>
<li>linux：设置环境变量<code>NLS_LANG</code>,等于<code>AMERICAN_AMERICA.AL32UTF8</code></li>
<li>windows: 设置环境变量<code>NLS_LANG</code>,等于<code>SIMPLIFIED CHINESE_CHINA.ZHS16GBK</code></li>
</ul>
<h2 id="start-with-connect-by-prior-用法？"><a href="#start-with-connect-by-prior-用法？" class="headerlink" title="start with... connect by prior...用法？"></a><code>start with... connect by prior...</code>用法？</h2><p>  以哪条数据开始，以父数据(prior)的字段作为子数据的另一个字段,依次递归查询，为一个树形结构。</p>
<h1 id="Sat-Dec-14-19-55-06-CST-2019"><a href="#Sat-Dec-14-19-55-06-CST-2019" class="headerlink" title="Sat Dec 14 19:55:06 CST 2019"></a>Sat Dec 14 19:55:06 CST 2019</h1><h2 id="ORA-01033-ORACLE-initialization-or-shutdown"><a href="#ORA-01033-ORACLE-initialization-or-shutdown" class="headerlink" title="ORA-01033:ORACLE initialization or shutdown ??"></a>ORA-01033:ORACLE initialization or shutdown ??</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">shutdown normal;</span><br><span class="line">startup mount;</span><br><span class="line">alter database open;</span><br><span class="line"></span><br><span class="line"># Mon Dec 16 09:03:54 CST 2019</span><br><span class="line">## ORA-03113: end-of-file on communication channel??</span><br><span class="line">[](https://blog.51cto.com/mister/1740508)</span><br><span class="line">​```sqlplus</span><br><span class="line">startup mount;</span><br><span class="line">startup nomount;</span><br><span class="line">exit;</span><br><span class="line">sqlplus / as sysdba</span><br><span class="line">startup mount;</span><br><span class="line">alter database open;</span><br></pre></td></tr></table></figure>
<h1 id="Mon-Dec-16-18-40-39-CST-2019"><a href="#Mon-Dec-16-18-40-39-CST-2019" class="headerlink" title="Mon Dec 16 18:40:39 CST 2019"></a>Mon Dec 16 18:40:39 CST 2019</h1><h2 id="命令行查看函数或者存储过程的源代码？"><a href="#命令行查看函数或者存储过程的源代码？" class="headerlink" title="命令行查看函数或者存储过程的源代码？"></a>命令行查看函数或者存储过程的源代码？</h2><ul>
<li><code>select text from (all_source)user_source where name=upper(&#39;swap_drb&#39;) order by line;</code></li>
<li><a target="_blank" rel="noopener" href="https://www.cnblogs.com/saptechnique/archive/2013/03/19/2969906.html">oralce-sqlplus命令详解</a></li>
</ul>
<h2 id="ORA-06575-程序包或函数-FUN-GET-SFZHM-BY-CZY-处于无效状态"><a href="#ORA-06575-程序包或函数-FUN-GET-SFZHM-BY-CZY-处于无效状态" class="headerlink" title="ORA-06575: 程序包或函数 FUN_GET_SFZHM_BY_CZY 处于无效状态?"></a>ORA-06575: 程序包或函数 FUN_GET_SFZHM_BY_CZY 处于无效状态?</h2><ul>
<li>错误原因<br>程序包或者函数编译不通过。</li>
</ul>
<h2 id="函数创建的基本格式？"><a href="#函数创建的基本格式？" class="headerlink" title="函数创建的基本格式？"></a>函数创建的基本格式？</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">创建函数的基本格式 create or replace function 函数名称(参数1 ，参数2) return 参数类型 is </span><br><span class="line">begin</span><br><span class="line">end</span><br></pre></td></tr></table></figure>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">--创建函数语法</span><br><span class="line">create [or replace] function [schema.]function_name</span><br><span class="line">(函数参数列表) --参数有IN、OUT、IN OUT三种类型；IN代表需要输入的参数，OUT代表要返回的参数，IN OUT代表即是输入参数也是返回参数。</span><br><span class="line">return datetype--返回类型</span><br><span class="line">[is | as ]---任选一个，后面跟pLSQL代码块</span><br><span class="line">[declare]--有参数时使用关键字</span><br><span class="line">begin</span><br><span class="line">  --执行的SQL</span><br><span class="line">end;</span><br></pre></td></tr></table></figure>
<h1 id="2019年12月31日-星期二-14时05分21秒-CST"><a href="#2019年12月31日-星期二-14时05分21秒-CST" class="headerlink" title="2019年12月31日 星期二 14时05分21秒 CST"></a>2019年12月31日 星期二 14时05分21秒 CST</h1><h2 id="for-in-loop-statement"><a href="#for-in-loop-statement" class="headerlink" title="for in loop statement"></a>for in loop statement</h2><p>oracle常见的三种循环结构</p>
<ul>
<li>loop statement end loop</li>
<li>while boolean expression loop statement end loop</li>
<li>for indexname in () loop statement end loop<br>examples<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">declare</span><br><span class="line">    v_num int;</span><br><span class="line">begin</span><br><span class="line">    for v_num in (reverse) 1..10 loop</span><br><span class="line">        dbms_output.PUT_LINE(&#x27;num:&#x27;||v_num);</span><br><span class="line">        end loop;</span><br><span class="line">end;</span><br></pre></td></tr></table></figure>
<h2 id="oracle打印日志输出"><a href="#oracle打印日志输出" class="headerlink" title="oracle打印日志输出"></a>oracle打印日志输出</h2><code>dbms_output.put_line()</code></li>
</ul>
<h2 id="oracle中join连接的几种方式"><a href="#oracle中join连接的几种方式" class="headerlink" title="oracle中join连接的几种方式"></a>oracle中join连接的几种方式</h2><ul>
<li>内连接(inner join),其中inner可以省略</li>
<li>外连接(left outer join,right outer join)，其中outer可以省略</li>
<li>…</li>
</ul>
<h2 id="table-函数的用法"><a href="#table-函数的用法" class="headerlink" title="table()函数的用法"></a>table()函数的用法</h2><ul>
<li>结合数组</li>
<li>结合pipelined函数</li>
<li>结合系统包<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">--1.</span><br><span class="line">explain plan for select * from usr_users t;</span><br><span class="line">select * from table(dbms_xplan.display);</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="plan-table-is-old-version的处理方法"><a href="#plan-table-is-old-version的处理方法" class="headerlink" title="plan_table is old version的处理方法"></a>plan_table is old version的处理方法</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">drop table plan_table;</span><br><span class="line">@?/rdbms/admin/utlxplan.sql;</span><br></pre></td></tr></table></figure>
<h2 id="使用执行计划进行sql优化"><a href="#使用执行计划进行sql优化" class="headerlink" title="使用执行计划进行sql优化"></a>使用执行计划进行sql优化</h2><ul>
<li>查看总COST，获得资源耗费的总体印象 </li>
<li>按照从左至右，从上至下的方法，了解执行计划的执行步骤 </li>
<li>分析表的访问方式<br>全表扫描（TABLE ACCESS FULL）和索引扫描(INDEX SCAN)</li>
<li>分析表的连接方式和连接顺序<br>嵌套循环（NESTED LOOPS）、哈希连接（HASH JOIN）和排序-合并连接（SORT MERGE JOIN）</li>
</ul>
<h1 id="2020年-1月-2日-星期四-09时01分39秒-CST"><a href="#2020年-1月-2日-星期四-09时01分39秒-CST" class="headerlink" title="2020年 1月 2日 星期四 09时01分39秒 CST"></a>2020年 1月 2日 星期四 09时01分39秒 CST</h1><h2 id><a href="#" class="headerlink" title=" "></a> </h2>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-plantUML/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-plantUML/" class="post-title-link" itemprop="url">notebook-plantUML</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>89</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Thu-Nov-7-13-01-51-CST-2019"><a href="#Thu-Nov-7-13-01-51-CST-2019" class="headerlink" title="Thu Nov  7 13:01:51 CST 2019"></a>Thu Nov  7 13:01:51 CST 2019</h1><h2 id="活动图-activity"><a href="#活动图-activity" class="headerlink" title="活动图(activity)"></a>活动图(activity)</h2><h2 id="甘特图-gantt"><a href="#甘特图-gantt" class="headerlink" title="甘特图(gantt)"></a>甘特图(gantt)</h2><h2 id="思维导图-mindmap"><a href="#思维导图-mindmap" class="headerlink" title="思维导图(mindmap)"></a>思维导图(mindmap)</h2><h2 id="工作分解结构-work-breakdwork-structure"><a href="#工作分解结构-work-breakdwork-structure" class="headerlink" title="工作分解结构(work breakdwork structure)"></a>工作分解结构(work breakdwork structure)</h2>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-python3/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-python3/" class="post-title-link" itemprop="url">notebook-python3</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>78</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="2020年-1月27日-星期一-14时00分08秒-CST"><a href="#2020年-1月27日-星期一-14时00分08秒-CST" class="headerlink" title="2020年 1月27日 星期一 14时00分08秒 CST"></a>2020年 1月27日 星期一 14时00分08秒 CST</h1><ol>
<li>分支结构</li>
</ol>
<p>结构存在顺序结构、选择(分支)结构、循环结构三种。</p>
<ul>
<li>选择结构<br><code>if...elif..else..</code>,``</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/16/notebook-vim/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/16/notebook-vim/" class="post-title-link" itemprop="url">notebook-vim</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-16 00:42:17" itemprop="dateCreated datePublished" datetime="2020-08-16T00:42:17+08:00">2020-08-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>78</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="Tue-Oct-29-09-44-54-CST-2019"><a href="#Tue-Oct-29-09-44-54-CST-2019" class="headerlink" title="Tue Oct 29 09:44:54 CST 2019"></a>Tue Oct 29 09:44:54 CST 2019</h1><h2 id="将时间表达式-read-date格式化成符合中国人识别的格式？"><a href="#将时间表达式-read-date格式化成符合中国人识别的格式？" class="headerlink" title="将时间表达式:read !date格式化成符合中国人识别的格式？"></a>将时间表达式<code>:read !date</code>格式化成符合中国人识别的格式？</h2><h2 id="修改文件保存的编码格式？"><a href="#修改文件保存的编码格式？" class="headerlink" title="修改文件保存的编码格式？"></a>修改文件保存的编码格式？</h2><h2 id="修改文件查看的编码格式？"><a href="#修改文件查看的编码格式？" class="headerlink" title="修改文件查看的编码格式？"></a>修改文件查看的编码格式？</h2>
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/14/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/14/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95/" class="post-title-link" itemprop="url">正则表达式基本语法</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-14 14:34:53" itemprop="dateCreated datePublished" datetime="2020-08-14T14:34:53+08:00">2020-08-14</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.2k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h4 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h4><p>正则表达式( regular expression ) 描述了一种字符串匹配的模式( pattern )，可以用来检查一个串是否含有某种字串、将匹配的子串替换或者从某个串中取出符合某个条件的字串等等。</p>
<p>几个栗子</p>
<figure class="highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">runoo+b，可以匹配 runoob、runooob、runoooooob 等，+ 号代表前面的字符必须至少出现一次（1次或多次）。</span><br><span class="line"></span><br><span class="line">runoo*b，可以匹配 runob、runoob、runoooooob 等，* 号代表前面的字符可以不出现，也可以出现一次或者多次（0次、或1次、或多次）。</span><br><span class="line"></span><br><span class="line">colou?r 可以匹配 color 或者 colour，? 问号代表前面的字符最多只可以出现一次（0次、或1次）。</span><br></pre></td></tr></table></figure>
<blockquote>
<p>构造正则表达式的方法和创建数学表达式的方法一样。也就是用多种元字符与运算符可以将小的表达式结合在一起来创建更大的表达式。正则表达式的组件可以是单个的字符、字符集合、字符范围、字符间的选择或者所有这些组件的任意组合。</p>
<p>正则表达式是由普通字符（例如字符 a 到 z）以及特殊字符（称为”元字符”）组成的文字模式。模式描述在搜索文本时要匹配的一个或多个字符串。正则表达式作为一个模板，将某个字符模式与所搜索的字符串进行匹配</p>
</blockquote>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/2020/08/14/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%9F%BA%E6%9C%AC%E8%AF%AD%E6%B3%95/#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://wrr123.github.io/2020/08/14/prettier%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="田园隐士">
      <meta itemprop="description" content="talk is cheap, show me the code">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一缕烟气">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/08/14/prettier%E5%9F%BA%E6%9C%AC%E4%BD%BF%E7%94%A8/" class="post-title-link" itemprop="url">prettier基本使用</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-14 14:10:21" itemprop="dateCreated datePublished" datetime="2020-08-14T14:10:21+08:00">2020-08-14</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-18 10:52:04" itemprop="dateModified" datetime="2022-02-18T10:52:04+08:00">2022-02-18</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>4.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>4 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h4 id="基本介绍"><a href="#基本介绍" class="headerlink" title="基本介绍"></a>基本介绍</h4><p>prettier 是一款强势武断的代码格式化工具，它几乎移除了编辑器本身所有的对代码的操作格式，然后重新显示。就是为了让所有用这套规则的人有完全相同的代码。在团队协作开发的时候，更是体现出它的优势。与 eslint，tslint 等各种格式化工具不同的是，prettier 只关心代码格式化，而不关心语法问题。</p>
<h4 id="使用的两种方式"><a href="#使用的两种方式" class="headerlink" title="使用的两种方式"></a>使用的两种方式</h4><h5 id="使用编辑器的插件"><a href="#使用编辑器的插件" class="headerlink" title="使用编辑器的插件"></a>使用编辑器的插件</h5><p>使用编辑器插件是最为方便的一种方法，编写完代码，只需要一键即可格式化编写的代码，非常的方便。</p>
<p>这是一个 vscode 的栗子：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="comment">// 使能每一种语言默认格式化规则</span></span><br><span class="line">    <span class="attr">&quot;[html]&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;editor.defaultFormatter&quot;</span><span class="punctuation">:</span> <span class="string">&quot;esbenp.prettier-vscode&quot;</span></span><br><span class="line">    <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;[css]&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;editor.defaultFormatter&quot;</span><span class="punctuation">:</span> <span class="string">&quot;esbenp.prettier-vscode&quot;</span></span><br><span class="line">    <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;[less]&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;editor.defaultFormatter&quot;</span><span class="punctuation">:</span> <span class="string">&quot;esbenp.prettier-vscode&quot;</span></span><br><span class="line">    <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;[javascript]&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;editor.defaultFormatter&quot;</span><span class="punctuation">:</span> <span class="string">&quot;esbenp.prettier-vscode&quot;</span></span><br><span class="line">    <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line">    </span><br><span class="line">    <span class="comment">/*  prettier的配置 */</span></span><br><span class="line">    <span class="attr">&quot;prettier.printWidth&quot;</span><span class="punctuation">:</span> <span class="number">100</span><span class="punctuation">,</span> <span class="comment">// 超过最大值换行</span></span><br><span class="line">    <span class="attr">&quot;prettier.tabWidth&quot;</span><span class="punctuation">:</span> <span class="number">4</span><span class="punctuation">,</span> <span class="comment">// 缩进字节数</span></span><br><span class="line">    <span class="attr">&quot;prettier.useTabs&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span> <span class="comment">// 缩进不使用tab，使用空格</span></span><br><span class="line">    <span class="attr">&quot;prettier.semi&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span><span class="punctuation">,</span> <span class="comment">// 句尾添加分号</span></span><br><span class="line">    <span class="attr">&quot;prettier.singleQuote&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span><span class="punctuation">,</span> <span class="comment">// 使用单引号代替双引号</span></span><br><span class="line">    <span class="attr">&quot;prettier.proseWrap&quot;</span><span class="punctuation">:</span> <span class="string">&quot;preserve&quot;</span><span class="punctuation">,</span> <span class="comment">// 默认值。因为使用了一些折行敏感型的渲染器（如GitHub comment）而按照markdown文本样式进行折行</span></span><br><span class="line">    <span class="attr">&quot;prettier.arrowParens&quot;</span><span class="punctuation">:</span> <span class="string">&quot;avoid&quot;</span><span class="punctuation">,</span> <span class="comment">//  (x) =&gt; &#123;&#125; 箭头函数参数只有一个时是否要有小括号。avoid：省略括号</span></span><br><span class="line">    <span class="attr">&quot;prettier.bracketSpacing&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span><span class="punctuation">,</span> <span class="comment">// 在对象，数组括号与文字之间加空格 &quot;&#123; foo: bar &#125;&quot;</span></span><br><span class="line">    <span class="attr">&quot;prettier.disableLanguages&quot;</span><span class="punctuation">:</span> <span class="punctuation">[</span><span class="string">&quot;vue&quot;</span><span class="punctuation">]</span><span class="punctuation">,</span> <span class="comment">// 不格式化vue文件，vue文件的格式化单独设置</span></span><br><span class="line">    <span class="attr">&quot;prettier.endOfLine&quot;</span><span class="punctuation">:</span> <span class="string">&quot;auto&quot;</span><span class="punctuation">,</span> <span class="comment">// 结尾是 \n \r \n\r auto</span></span><br><span class="line">    <span class="attr">&quot;prettier.eslintIntegration&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span> <span class="comment">//不让prettier使用eslint的代码格式进行校验</span></span><br><span class="line">    <span class="attr">&quot;prettier.htmlWhitespaceSensitivity&quot;</span><span class="punctuation">:</span> <span class="string">&quot;ignore&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;prettier.ignorePath&quot;</span><span class="punctuation">:</span> <span class="string">&quot;.prettierignore&quot;</span><span class="punctuation">,</span> <span class="comment">// 不使用prettier格式化的文件填写在项目的.prettierignore文件中</span></span><br><span class="line">    <span class="attr">&quot;prettier.jsxBracketSameLine&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span> <span class="comment">// 在jsx中把&#x27;&gt;&#x27; 是否单独放一行</span></span><br><span class="line">    <span class="attr">&quot;prettier.jsxSingleQuote&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span> <span class="comment">// 在jsx中使用单引号代替双引号</span></span><br><span class="line">    <span class="attr">&quot;prettier.parser&quot;</span><span class="punctuation">:</span> <span class="string">&quot;babylon&quot;</span><span class="punctuation">,</span> <span class="comment">// 格式化的解析器，默认是babylon</span></span><br><span class="line">    <span class="attr">&quot;prettier.requireConfig&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span> <span class="comment">// Require a &#x27;prettierconfig&#x27; to format prettier</span></span><br><span class="line">    <span class="attr">&quot;prettier.stylelintIntegration&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span> <span class="comment">//不让prettier使用stylelint的代码格式进行校验</span></span><br><span class="line">    <span class="attr">&quot;prettier.trailingComma&quot;</span><span class="punctuation">:</span> <span class="string">&quot;es5&quot;</span><span class="punctuation">,</span> <span class="comment">// 在对象或数组最后一个元素后面是否加逗号（在ES5中加尾逗号）</span></span><br><span class="line">    <span class="attr">&quot;prettier.tslintIntegration&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span> <span class="comment">// 不让prettier使用tslint的代码格式进行校验</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>
<h6 id="如何使用-prettier-来格式化-vue-的代码"><a href="#如何使用-prettier-来格式化-vue-的代码" class="headerlink" title="如何使用 prettier 来格式化 vue 的代码"></a>如何使用 prettier 来格式化 vue 的代码</h6><p>在配置文件中加入下面的话，prettier 是不生效的。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;[vue]&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;editor.defaultFormatter&quot;</span><span class="punctuation">:</span> <span class="string">&quot;esbenp.prettier-vscode&quot;</span></span><br><span class="line">    <span class="punctuation">&#125;</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>
<p><strong>但是可以使用 Vetur 插件，Vetur 默认是使用 prettier 进行格式化的，不过 Vetur 的默认格式配置与我们期望的是有所出入的</strong></p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">    <span class="attr">&quot;vetur.format.defaultFormatter.html&quot;</span><span class="punctuation">:</span> <span class="string">&quot;prettier&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vetur.format.defaultFormatter.js&quot;</span><span class="punctuation">:</span> <span class="string">&quot;prettier&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vetur.format.defaultFormatter.less&quot;</span><span class="punctuation">:</span> <span class="string">&quot;prettier&quot;</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">&quot;vetur.format.defaultFormatterOptions&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">        <span class="attr">&quot;prettier&quot;</span><span class="punctuation">:</span> <span class="punctuation">&#123;</span></span><br><span class="line">            <span class="attr">&quot;printWidth&quot;</span><span class="punctuation">:</span> <span class="number">160</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;singleQuote&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span><span class="punctuation">,</span> <span class="comment">// 使用单引号</span></span><br><span class="line">            <span class="attr">&quot;semi&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span><span class="punctuation">,</span> <span class="comment">// 末尾使用分号</span></span><br><span class="line">            <span class="attr">&quot;tabWidth&quot;</span><span class="punctuation">:</span> <span class="number">4</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;arrowParens&quot;</span><span class="punctuation">:</span> <span class="string">&quot;avoid&quot;</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;bracketSpacing&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">&quot;proseWrap&quot;</span><span class="punctuation">:</span> <span class="string">&quot;preserve&quot;</span> <span class="comment">// 代码超出是否要换行 preserve保留</span></span><br><span class="line">        <span class="punctuation">&#125;</span></span><br><span class="line">    <span class="punctuation">&#125;</span><span class="punctuation">,</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br></pre></td></tr></table></figure>
<h5 id="使用脚本的方式"><a href="#使用脚本的方式" class="headerlink" title="使用脚本的方式"></a>使用脚本的方式</h5><blockquote>
<p>这种方式就是使用prettier指令在命令行窗口对单一文件进行格式化。 首先需要安装prettier全局指令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">npm install -g prettier</span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p>可以使用 <code>prettier -v</code> 检查是否安装完成。</p>
<p>安装好之后，使用下面指令对xxx.js文件进行格式化（使用的是prettier默认的配置规则）。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">// //prettier--write &lt;文件路劲+文件名&gt;</span><br><span class="line"></span><br><span class="line">prettier --write ./xxx.js</span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p>当然，默认的配置规则是不符合我们的需求的，我们需要自定义配置规则。 书写自定义规则的文件需要是下面几种文件和格式：</p>
<ul>
<li>.prettierrc 文件，支持yaml和json格式；或者加上 .yaml/.yml/.json 后缀名</li>
<li>.prettierrc.toml 文件（当为toml格式的时候，后缀是必须的）</li>
<li>prettier.config.js 或者 .prettierrc.js，需要返回一个对象</li>
<li>package.json文件中加上”prettier”属性</li>
</ul>
<p>每种文件的书写格式如下： <strong>JSON</strong></p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">&#123;</span></span><br><span class="line">  <span class="attr">&quot;trailingComma&quot;</span><span class="punctuation">:</span> <span class="string">&quot;es5&quot;</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;tabWidth&quot;</span><span class="punctuation">:</span> <span class="number">4</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;semi&quot;</span><span class="punctuation">:</span> <span class="keyword">false</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">&quot;singleQuote&quot;</span><span class="punctuation">:</span> <span class="keyword">true</span></span><br><span class="line"><span class="punctuation">&#125;</span></span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p><strong>JS</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// prettier.config.js or .prettierrc.js</span></span><br><span class="line"><span class="variable language_">module</span>.<span class="property">exports</span> = &#123;</span><br><span class="line">  <span class="attr">trailingComma</span>: <span class="string">&quot;es5&quot;</span>,</span><br><span class="line">  <span class="attr">tabWidth</span>: <span class="number">4</span>,</span><br><span class="line">  <span class="attr">semi</span>: <span class="literal">false</span>,</span><br><span class="line">  <span class="attr">singleQuote</span>: <span class="literal">true</span></span><br><span class="line">&#125;;</span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p><strong>YAML</strong></p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># .prettierrc or .prettierrc.yaml</span></span><br><span class="line"><span class="attr">trailingComma:</span> <span class="string">&quot;es5&quot;</span></span><br><span class="line"><span class="attr">tabWidth:</span> <span class="number">4</span></span><br><span class="line"><span class="attr">semi:</span> <span class="literal">false</span></span><br><span class="line"><span class="attr">singleQuote:</span> <span class="literal">true</span></span><br><span class="line"><span class="string">复制代码</span></span><br></pre></td></tr></table></figure>
<p><strong>TOML</strong></p>
<figure class="highlight toml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># .prettierrc.toml</span></span><br><span class="line"><span class="attr">trailingComma</span> = <span class="string">&quot;es5&quot;</span></span><br><span class="line"><span class="attr">tabWidth</span> = <span class="number">4</span></span><br><span class="line"><span class="attr">semi</span> = <span class="literal">false</span></span><br><span class="line"><span class="attr">singleQuote</span> = <span class="literal">true</span></span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p>prettier 查找配置的方式首先会找当前目录下，使用以下指令格式化代码：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">//prettier --config --write &lt;文件路劲+文件名&gt;</span><br><span class="line"></span><br><span class="line"> prettier --config --write ./xxx,js</span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p>如果prettier在当前目录找不到配置文件，会一直向上级目录查找，直到找到或找不到。如果我们配置文件放在别的地方，则需要手工指定配置文件的路径：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">// prettier --config &lt;配置文件路径+文件名&gt; --write &lt;文件路劲+文件名&gt;</span><br><span class="line"></span><br><span class="line">prettier --config ./prettier/.prettierrc --write ./xxx.js</span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p>如果觉得每次格式化一个文件比较麻烦，可以使用下面的指令，一次格式化所有文件：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">prettier --config ./prettier/.prettierrc --write <span class="string">&#x27;./*.&#123;ts,js,css,json&#125;&#x27;</span></span><br><span class="line">复制代码</span><br></pre></td></tr></table></figure>
<p>我们一般使用这种方式的时候，就把这个配置文件写在项目根路径下，然后使用命令行一次性格式化项目下的所有文件。</p>
</blockquote>
<h5 id="上述两种方式的对比"><a href="#上述两种方式的对比" class="headerlink" title="上述两种方式的对比"></a>上述两种方式的对比</h5><blockquote>
<p>上面两种方式各有优劣，我们来分析一下各自的使用场景和一些问题：</p>
<p><strong>第一种方式其实适合个人开发，第二种方式适合团队开发。</strong></p>
<p>至于为什么这么说，就要考虑到二者的优先级问题了。上面两种方式如果同时存在的话，会有优先级的问题。 <strong>.prettierrc 的优先级会高于在vscode全局配置settings.json中格式化配置的优先级</strong></p>
<p>也就是说，如果你在一个项目中有 .prettierrc 配置文件，然后你又在settings.json也配置了格式化规则，那么当你在vscode编辑器中对一个文件点击鼠标右键[格式化文档]的时候，格式化规则会以 .prettierrc 为准。</p>
<p>所以，由于编辑器settings.json每个人的设置可能都不一样，要求每个人统一设置也不方便操作，而嵌入在项目中的配置文件则可以随着项目到达各个开发者，而且会覆盖每个开发者的不同代码喜好，真正做到团队代码统一的效果。</p>
</blockquote>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/26/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/26/">26</a><span class="page-number current">27</span><a class="page-number" href="/page/28/">28</a><span class="space">&hellip;</span><a class="page-number" href="/page/35/">35</a><a class="extend next" rel="next" href="/page/28/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">田园隐士</p>
  <div class="site-description" itemprop="description">talk is cheap, show me the code</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">347</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">53</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
        <span class="site-state-item-count">115</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">田园隐士</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">587k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">8:53</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  

  

</body>
</html>
